package org.millioncall.yueyoga.admin.export;
import java.util.List;

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.millioncall.yueyoga.admin.model.Recharge;

public class RechargeExportTemplate extends AbstractExcelExportTemplate{

	private List<Recharge> recharges;
	String[] titles = new String[] { "编号", "金额", "会员", "操作员","类型", "备注", "时间"};
	
	public RechargeExportTemplate(List<Recharge> recharges) {
		this.recharges = recharges;
	}
	
	@Override
	public String[] getSheetNames() {
		return new String[] { "资金日志信息表" };
	}
	
	@Override
	public String[][] getTitles() {
		return new String[][] { titles };
	}
	
	@Override
	protected void buildBody(int sheetIndex) {
		Sheet sheet = getSheet(sheetIndex);
		int startIndex = this.getBodyStartIndex(sheetIndex);
		for (int i = 0; i < this.recharges.size(); i++) {
			Recharge recharge = this.recharges.get(i);
	
			Row row = sheet.createRow(i + startIndex);
			row.setHeight((short) 300);
			int index = 0;
			createStyledCell(row, index++, recharge.getRechargeId()==null?"":recharge.getRechargeId().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, recharge.getMoney()==null?"":recharge.getMoney().toString(), this.bodyRowStyle);
			if(recharge.getMember()!=null){
				createStyledCell(row, index++, recharge.getMember().getName(), this.bodyRowStyle);
			}else{
				createStyledCell(row, index++, "", this.bodyRowStyle);
			}
			createStyledCell(row, index++, recharge.getUser()==null?"":recharge.getUser().getUserDetail().getName(), this.bodyRowStyle);
			createStyledCell(row, index++, recharge.getLogType()==null?"":recharge.getLogType(), this.bodyRowStyle);
			createStyledCell(row, index++, recharge.getRemarks()==null?"":recharge.getRemarks(), this.bodyRowStyle);
			createStyledCell(row, index++, recharge.getCreateTime()==null?"":recharge.getCreateTime().substring(0, 19).toString() , this.bodyRowStyle);
		}
	}
	
	@Override
	public String[] getCaptions() {
		return new String[] { "资金日志信息表" };
	}
}

